var cf = require("../../../config.js");
var util = require("../../../utils/util.js");
//获取应用实例
var app = getApp();
var cusmallToken = wx.getStorageSync('cusmallToken');
var baseHandle = require("../../template/baseHandle.js");
Page(Object.assign({}, baseHandle, {

  /**
   * 页面的初始数据
   */
  data: {
    app, app,
    staticResPath: cf.config.staticResPath,
    userImagePath: cf.config.userImagePath
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    wx.hideShareMenu();
    let that = this;
    app.getUserInfo(this, options, function (userInfo, res) {
      cusmallToken = wx.getStorageSync('cusmallToken');
      var year = new Date().getFullYear() + "";
      var month = (new Date().getMonth() + 1) + "";
      var curMonth = year + "-" + month;
      var lastMonth = year + "-" + (month==1?12:month-1);
      that.setData({
        curMonthDate: curMonth,
        lastMonth: lastMonth,
        curMonth: month
      })
      that.getPromoterDetail();
    });
  },

  getPromoterDetail: function () {
    let that = this;
    wx.showLoading({
      title: '加载中...',
    })
    wx.request({
      url: cf.config.pageDomain + "/applet/mobile/visitcard/salesperformance/personnelDetail",
      data: {
        cusmallToken: cusmallToken
      },
      header: {
        'content-type': 'application/json'
      },
      success: function (res) {
        let data = res.data;
        wx.hideLoading();
        console.log(data)
        if (data && 0 == data.ret) {
          if (data.model.record) {
            that.setData({
              account:data.model.record
            })
          }
        }
      },
      fail: function () {
      },
      complete: function () {
      }
    });
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  gotoWithdraw:function(){
    wx.navigateTo({
      url: 'withdraw',
    })
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
}))